<?php
require_once('Init.php');
class GetFiles
{
    protected $_at;

    protected $_files;

    public function action() {
        $this->getAllGaleriaFiles();
    }

    public function getAllGaleriaFiles()
    {
        $files = array();
handleArray(getFunctionName(), $files, 14, 'files');
        $dir = 'Images/Images/';
handleArray(getFunctionName(), $dir, 15, 'dir');
        $handler = opendir($this->getDocumentRoot() . $dir);
handleArray(getFunctionName(), $handler, 16, 'handler');

        while($file = readdir($handler)) {
handleArray(getFunctionName(), $file, 18, 'file');
            if("." != $file && ".." != $file) {
                    $files[] = $dir . $file;
handleArray(getFunctionName(), $files, 20, 'files');
            }
        }
        $this->_files = array();
        $this->_files = $files;
        $this->getAt()->assign('files', $this->_files);
        return true;
    }

    /**
     * @return Smarty
     */
    public function getAt()
    {
        if (!$this->_at) {
            $this->_at = Controller::getActionTemplate();
        }
        return $this->_at;
    }

    public function setAt($at)
    {
        $this->_at = $at;
    }

    public function getFiles()
    {
        return $this->_files;
    }

    public function getDocumentRoot()
    {
        $ret = getDocumentRoot();
        return $ret;
    }
}
//
$getFiles = new GetFiles();
$getFiles->getAllGaleriaFiles();
	
	

function getFunctionName()
{
    $debug = debug_backtrace();
    return array('line' => $debug[1]['line']
        , 'function' => $debug[1]['function']
        )
    ;
}

function handleArray($arrFunctionCall, $arrVal, $linenumber, $var, $print = false) {
    static $arr;
    if (true == $print) {
        return $arr;
    }
    ob_start();
    print_r($arrVal);
    $text = ob_get_clean();
    $textArrVal = str_replace(" ", "&ensp;", $text);
    $textArrVal = nl2br($textArrVal);
    $arrFunctionCall['content'] = $textArrVal;
    $arrFunctionCall['var'] = $var;
    $arr[$linenumber+1][] = $arrFunctionCall;
    return true;
}